<template>
  <div id="keyInspectionAdd">
    <div class="top">
      <p
        v-if="isZJ"
        style="text-align: center; font-weight: bold; padding: 10px 0"
      >
        自建房安全隐患自(排)查记录表
      </p>
      <p v-else style="text-align: center; font-weight: bold; padding: 10px 0">
        非自建房安全隐患自（排）查记录表
      </p>
      <van-field
        required
        :readonly="!isAdd"
        v-model="formDataPC.CREATE_USER"
        placeholder="请输入排查人"
        label="排查人"
      />
      <van-field
        required
        :readonly="!isAdd"
        clickable
        name="datetimePicker"
        v-model="formDataPC.pcsj"
        label="排查时间"
        placeholder="请选择排查时间"
        @click="isAdd ? (showPickerq = true) : ''"
      />
      <van-popup v-model="showPickerq" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="date"
          title="选择年月日"
          @cancel="showPickerq = false"
          @confirm="onConfirm"
          :min-date="minDate"
          :max-date="maxDate"
        />
      </van-popup>
    </div>
    <div class="content">
      <div>
        <p style="display: flex; justify-items: center; padding: 10px 0">
          <span class="line"></span>
          灾普信息
        </p>
        <van-form validate-first>
          <van-field
            required
            :readonly="!isAdd"
            v-model="formHZXX.hZXM"
            placeholder="请输入使用人姓名"
            label="使用人姓名"
          />
          <van-field
            required
            :readonly="!isAdd"
            v-model="formHZXX.hZSFZH"
            label="使用人身份证号"
            placeholder="请输入使用人身份证号"
            :rules="[{ validator, message: '请输入正确身份证号码' }]"
          />
          <van-field
            :readonly="!isAdd"
            v-model="formHZXX.hZDH"
            label="使用人联系电话"
            placeholder="请输入使用人联系电话"
            :rules="[
              { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
            ]"
          />
          <van-field
            required
            :readonly="!isAdd"
            v-model="formHZXX.zP_FWBH"
            placeholder="请输入灾普房屋编号"
            label="灾普房屋编号"
          />
          <van-field
            @click="handleClick(item)"
            :readonly="!isAdd"
            v-model="formHZXX.fW_ADDRESS"
            placeholder="请输入房屋地址"
            label="房屋地址"
          />
          <!--<el-button style="float:right;margin-top:-34px" @click="handleGoMap"  type="primary" size="mini">定位</el-button>-->
        </van-form>
      </div>
      <div v-if="false">
        <p style="display: flex; justify-items: center; padding: 10px 0">
          <span class="line"></span>
          房屋基础信息
        </p>
        <div v-if="isZJ">
          <van-form validate-first>
            <van-field
              required
              :readonly="!isAdd"
              v-model="formData.CQRHSYRXM"
              placeholder="请输入使用人姓名"
              label="使用人姓名"
            />
            <van-field
              required
              :readonly="!isAdd"
              v-model="formData.CQRHSYRZJHM"
              placeholder="请输入使用人身份证号"
              label="使用人身份证号"
              :rules="[{ validator, message: '请输入正确身份证号码' }]"
            />
            <van-field
              required
              :readonly="!isAdd"
              v-model="formData.CQRHSYRZJDH"
              placeholder="请输入使用人联系电话"
              label="使用人联系电话"
              :rules="[
                { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
              ]"
            />
          </van-form>
        </div>
        <div v-if="!isZJ">
          <!--<van-field required :readonly="!isAdd" v-model="formData.CQRHSYR"   placeholder="请输入产权人(或使用人)" label="产权人(或使用人)" />-->
          <van-field
            required
            :readonly="!isAdd"
            v-model="formData.XMHZJGMC"
            placeholder="请输入产权人(或使用人)"
            label="请输入产权人(或使用人)"
          />
          <van-field
            readonly
            clickable
            required
            name="picker"
            :value="formData.CQRHSYRZJLX | inUseName(columnsZJLX)"
            label="证件类型"
            placeholder="请选择"
            @click="isAdd ? (showPickerJGLX = true) : ''"
          />
          <van-popup v-model="showPickerJGLX" position="bottom" get-container="#popup">
            <van-picker
              show-toolbar
              :columns="columnsZJLX"
              value-key="DICNAME"
              @confirm="onConfirmJGLX"
              @cancel="isAdd ? (showPickerJGLX = false) : ''"
            />
          </van-popup>
          <van-field
            required
            :readonly="!isAdd"
            v-model="formData.CQRHSYRZJHM"
            placeholder="请输入证件号码"
            label="证件号码"
          />
          <van-field
            readonly
            required
            clickable
            name="picker"
            :value="formData.CQXZ | inUseName(columnsCQXZ)"
            label="产权性质"
            placeholder="请选择"
            @click="isAdd ? (showPickerCQXZ = true) : ''"
          />

          <van-popup v-model="showPickerCQXZ" position="bottom" get-container="#popup">
            <van-picker
              value-key="DICNAME"
              show-toolbar
              :columns="columnsCQXZ"
              @confirm="onConfirmCQXZ"
              @cancel="showPickerCQXZ = false"
            />
          </van-popup>
          <!--          <van-field-->
          <!--            readonly-->
          <!--            clickable-->
          <!--            name="picker"-->
          <!--            v-model="formData.SSHYXT"-->
          <!--            label="所属行业、系统"-->
          <!--            placeholder="请选择"-->
          <!--            @click="isAdd?showPickerSSHYXT = true:''"-->
          <!--          />-->

          <!--          <van-popup v-model="showPickerSSHYXT" position="bottom">-->
          <!--            <van-picker value-key="DICNAME" show-toolbar :columns="columnsSSHYXT" @confirm="onConfirmSSHYXT" @cancel="showPickerSSHYXT = false" />-->
          <!--          </van-popup>-->
          <van-field
            required
            :readonly="!isAdd"
            v-model="formData.JZMC"
            placeholder="请输入房屋或单位名称"
            label="房屋或单位名称"
          />
        </div>
        <div v-for="(item, index) in FWJCXXData" :key="index">
          <div v-if="item.type == 'input'">
            <van-field
              :required="item.required"
              :style="{ width: item.name == '房屋地址' ? '84%' : '100%' }"
              @click="handleClick(item)"
              :readonly="!isAdd"
              v-model="formData[item.key]"
              :placeholder="item.placeholder"
              :label="item.name"
            />
            <el-button
              style="float: right; margin-top: -34px"
              @click="handleGoMap"
              v-if="item.name == '房屋地址'"
              type="primary"
              size="mini"
              >定位</el-button
            >
          </div>
          <div v-if="item.type == 'select'" @click="handleClick1(item.name)">
            <van-field
              readonly
              :required="item.required"
              clickable
              name="picker"
              :label="item.name"
              placeholder="请选择"
              :value="formData[item.key] | inUseName(item.ARR)"
              @click="isAdd ? (item.active = true) : ''"
            />
            <van-popup v-model="item.active" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                value-key="DICNAME"
                :columns="item.ARR"
                @confirm="onConfirmALL"
                @cancel="item.active = false"
              />
            </van-popup>
          </div>
          <div v-if="item.type == 'date'">
            <van-field
              clickable
              :required="item.required"
              name="datetimePicker"
              v-model="formData[item.key]"
              :label="item.name"
              placeholder="请选择"
              @click="isAdd ? (item.active = true) : ''"
            />
            <van-popup v-model="item.active" position="bottom">
              <van-datetime-picker
                v-model="currentDate"
                :min-date="minDate"
                :max-date="maxDate"
                type="date"
                title="选择年月日"
                @cancel="item.active = false"
                @confirm="onConfirmSJ"
              />
            </van-popup>
          </div>
        </div>
      </div>
      <p style="display: flex; justify-items: center; padding: 10px 0">
        <span class="line"></span>
        排查信息
      </p>
      <div class="list">
        <ul>
          <li
            v-for="(item, index) in contentData"
            :key="index + 'contentData'"
            :style="{
              borderBottom:
                index === contentData.length - 1 ? 'none' : '1px solid #D2D2D2',
            }"
          >
            <span style="color: red">*</span>
            <span style="color: #007aff">{{ item.name }}</span>
            <div size="mini">
              <p
                class="btn-style"
                v-for="(item1, index1) in item.children"
                :key="index1 + 'children'"
                :style="{
                  borderBottom:
                    item.children.length - 1 === index1 ? 'none' : '',
                }"
                :label="item1.name"
              >
                <span v-if="item1.type == 'select'" style="padding-top: 10px">
                  <van-field
                    style="padding: 10px 0"
                    readonly
                    :required="item1.required"
                    clickable
                    name="picker"
                    :value="formDataPC[item1.key] | inUseName(item1.ARR)"
                    :label="item1.name"
                    placeholder="请选择"
                    @click="
                      item1.name !== '安全隐患初判'
                        ? isAdd
                          ? (item1.active = true)
                          : ''
                        : ''
                    "
                  />
                  <van-popup v-model="item1.active" position="bottom" get-container="#popup">
                    <van-picker
                      :required="item1.required"
                      value-key="DICNAME"
                      show-toolbar
                      :columns="item1.ARR"
                      @confirm="onConfirmContent"
                      @cancel="item1.active = false"
                    />
                  </van-popup>
                </span>
                <span v-else-if="item1.type == 'text'" style="font-size: 14px">
                  <!--<span v-if="formDataPC[item1.key]=='0'">{{item1.value}}</span>-->
                  <!--<span v-if="formDataPC[item1.key]=='1'">{{item1.value1}}</span>-->
                </span>
                <span v-else-if="item1.type == 'Checkbox'">
                  <van-radio-group
                    v-model="radioData"
                    direction="horizontal"
                    @change="radioChange"
                    :disabled="!isAdd "
                  >
                    <van-radio
                      shape="square"
                      style="margin-bottom: 5px; font-size: 14px"
                      v-for="(item2, index2) in item1.children"
                      :key="index2 + 'childrens'"
                      :name="item2.name"
                      >{{ item2.name }}
                    </van-radio>
                  </van-radio-group>
                </span>
                <span v-else-if="item1.type == 'input'">
                  <van-field
                    :required="item1.required"
                    :readonly="!isAdd"
                    v-model="formDataPC[item1.key]"
                    :placeholder="item1.placeholder"
                    :label="item1.name"
                  />
                </span>
                <span v-else>
                  <span
                    style="
                      width: 60%;
                      display: inline-block;
                      line-height: initial;
                      font-size: 14px;
                    "
                    >{{ item1.name }}</span
                  >
                  <span style="float: right; padding-top: 10px">
                    <van-radio-group
                      v-model="formDataPC[item1.key]"
                      @change="radioChangef(item1, item)"
                      direction="horizontal"
                      :disabled=" !isAdd "
                    >
                      <van-radio
                        name="0"
                        @click="radioClick(item1, item)"
                        shape="square"
                        >是</van-radio
                      >
                      <van-radio
                        name="1"
                        @click="radioClick(item1, item)"
                        shape="square"
                        >否</van-radio
                      >
                    </van-radio-group>
                  </span>
                  <span
                    v-for="(item3, index3) in item1.fileData"
                    :key="index3 + 'fileData3'"
                  >
                    <van-uploader
                      :disabled="!isAdd"
                      @click-upload="getList(item3)"
                      :after-read="afterRead"
                      :before-delete="delectFile"
                      v-model="item3.fileList"
                      accept=".jpg,.gif,.png,.jpeg"
                      multiple
                    />
                  </span>
                </span>
              </p>
              <div
                v-for="(item2, index2) in item.fileData"
                :key="index2 + 'fileData'"
              >
                <p style="font-size: 14px">
                  <span v-if="item2.name == '房屋整体照片'" style="color: red"
                    >*</span
                  >
                  {{ item2.name }}
                </p>
                <van-uploader
                  :disabled="!isAdd"
                  @click-upload="getList(item2)"
                  :after-read="afterRead"
                  :before-delete="delectFile"
                  v-model="item2.fileList"
                  accept=".jpg,.gif,.png,.jpeg"
                  multiple
                />
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <van-popup v-model:show="IsShowAre" round position="bottom">
      <van-cascader
        v-model="cascaderValue"
        title="选择房屋地址"
        :options="options"
        @close="closeA"
        @change="onChange"
        @finish="onFinish"
      />
    </van-popup>
    <div class="footer" v-if="isAdd">
      <!--<van-button size="small" type="info" @click="saveData">保存</van-button>-->
      <van-button size="small" style="width: 90%;" type="info" @click="updateData">提交</van-button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import {
  QuerySignCallback,
  InsertDataView,
  PrepareCreateProcess,
  CreateProcess,
  PlatSendTask,
  getRegister1,
  getRegister,
  getSystemCityCode,
  FileServerProxy,
  FileServerUpload,
  dataTransFile,
  LoadGridData,
  dataServerOpenDataView,
  DelectFile,
  GetFileData,
  existHouseBaseInfo,
  houseCheckDetail,
  saveOrUpdate,
  changePcztByFwId,
  GetAdministrative,
  dataTransFilePreview,
} from "../../../utils/api";
import dd from "gdt-jsapi";
export default {
  name: "keyInspectionAdd",
  data() {
    return {
      disabled:true,
      FWTYBH: "",
      nowIndex: "",
      areaCode: "",
      isFWLX: "",
      typeData: "",
      fwIdData: "",
      cascaderValue: "",
      options: [
        // {
        //   text: "杭州市",
        //   value: "441300000000",
        //   children: [],
        // },
      ],
      FWJCXXData: [
        {
          name: "房屋地址",
          key: "SEATNAME",
          type: "input",
          placeholder: "请输入房屋地址",
          required: true,
        },
        {
          name: "详细地址",
          key: "XXDZ",
          type: "input",
          placeholder: "请输入详细地址",
          required: true,
          children: [
            {
              name: "定位",
              type: "button",
            },
          ],
        },
        {
          name: "是否四类重点农房",
          key: "isFourImport",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "是",
              DICID: "0",
            },
            {
              DICNAME: "否",
              DICID: "1",
            },
          ],
        },
        // {
        //   name:'四类重点农房',
        //   key:'fourImportType',
        //   type:'select',
        //   active:false,
        //   ARR:[
        //     {
        //       DICNAME:"生产经营",
        //       DICID:0
        //     },
        //     {
        //       DICNAME:"人员集聚",
        //       DICID:1
        //     },
        //     {
        //       DICNAME:"改扩建",
        //       DICID:2
        //     },
        //   ]
        // },
        {
          name: "土地性质",
          key: "TDXZ",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "宅基地",
              DICID: "0",
            },
            {
              DICNAME: "非宅基地",
              DICID: "1",
            },
          ],
        },
        {
          name: "建成时间",
          key: "JCSJ",
          type: "select",
          required: true,
          active: false,
          ARR: [],
        },
        {
          name: "建筑层数",
          key: "JZCS",
          type: "input",
          required: true,
          placeholder: "请输入建筑层数",
        },
        {
          name: "其中地下层数",
          key: "DXCS",
          type: "input",
          placeholder: "请输入其中地下",
        },
        {
          name: "其中地上层数",
          key: "DSCS",
          type: "input",
          placeholder: "请输入其中地上",
        },
        {
          name: "建筑面积(m²)",
          key: "JZMJ",
          type: "input",
          required: true,
          placeholder: "请输入建筑面积",
        },
        {
          name: "结构类型",
          key: "JGLX",
          type: "select",
          required: true,
          active: false,
          ARR: [
            {
              DICNAME: "砖石结构（预制板）",
              DICID: "0",
            },
            {
              DICNAME: "砖石结构（非预制板）",
              DICID: "1",
            },
            {
              DICNAME: "土木结构",
              DICID: "2",
            },
            {
              DICNAME: "混凝土结构",
              DICID: "3",
            },
            {
              DICNAME: "钢结构",
              DICID: "4",
            },
            {
              DICNAME: "混杂结构",
              DICID: "5",
            },
            {
              DICNAME: "其他",
              DICID: "6",
            },
          ],
        },
        {
          name: "是否采用专业设计或标准图集",
          key: "isAtlas",
          type: "select",
          required: true,
          active: false,
          ARR: [
            {
              DICNAME: "是",
              DICID: "0",
            },
            {
              DICNAME: "否",
              DICID: "1",
            },
          ],
        },
        {
          name: "改造情况",
          key: "SFGZ",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "未改造",
              DICID: "0",
            },
            {
              DICNAME: "有改造",
              DICID: "1",
            },
          ],
        },
        {
          name: "改造方式",
          key: "GZFS",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "楼顶加层",
              DICID: "0",
            },
            {
              DICNAME: "周边扩建",
              DICID: "1",
            },
            {
              DICNAME: "楼内夹层",
              DICID: "2",
            },
            {
              DICNAME: "改变承重结构",
              DICID: "3",
            },
            {
              DICNAME: "下挖",
              DICID: "4",
            },
            {
              DICNAME: "其他",
              DICID: "5",
            },
          ],
        },
        {
          name: "鉴定情况",
          key: "isJD",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "未鉴定",
              DICID: "0",
            },
            {
              DICNAME: "已鉴定",
              DICID: "1",
            },
          ],
        },
        {
          name: "鉴定等级",
          key: "JDDJ",
          type: "select",
          active: false,
          required: true,
          ARR: [
            {
              DICNAME: "A级",
              DICID: "0",
            },
            {
              DICNAME: "B级",
              DICID: "1",
            },
            {
              DICNAME: "C级",
              DICID: "2",
            },
            {
              DICNAME: "D级",
              DICID: "3",
            },
          ],
        },
        {
          name: "建筑用途",
          key: "JZYT",
          type: "select",
          required: true,
          active: false,
          ARR: [
            {
              DICNAME: "餐饮服务",
              DICID: "0",
            },
            {
              DICNAME: "民宿宾馆",
              DICID: "1",
            },
            {
              DICNAME: "批发零售",
              DICID: "2",
            },
            {
              DICNAME: "医疗卫生",
              DICID: "3",
            },
            {
              DICNAME: "休闲娱乐",
              DICID: "4",
            },
            {
              DICNAME: "生产加工",
              DICID: "5",
            },
            {
              DICNAME: "仓储物流",
              DICID: "6",
            },
            {
              DICNAME: "出租房",
              DICID: "7",
            },
            {
              DICNAME: "自住",
              DICID: "9",
            },
            {
              DICNAME: "其他",
              DICID: "8",
            },
          ],
        },
        {
          name: "是否有营业执照",
          key: "hasTicket",
          type: "select",
          required: true,
          active: false,
          ARR: [
            {
              DICNAME: "是",
              DICID: "0",
            },
            {
              DICNAME: "否",
              DICID: "1",
            },
          ],
        },
        {
          name: "营业执照编号",
          key: "TicketNumber",
          type: "input",
          required: true,
          placeholder: "请输入营业执照编号",
        },
        // {
        //   name:'楼屋面类型',
        //   key:'houseSideType',
        //   type:'select',
        //   active:false,
        //   ARR:[
        //     {
        //       DICNAME:"空心板",
        //       DICID:0
        //     },
        //     {
        //       DICNAME:"瓦屋面",
        //       DICID:1
        //     },
        //     {
        //       DICNAME:"现浇",
        //       DICID:2
        //     },
        //     {
        //       DICNAME:"其他",
        //       DICID:3
        //     }
        //   ]
        // },
      ],
      // 是否是自建房
      isZJ: true,
      // 是否是新增
      isAdd: true,
      currentDate: new Date(),
      minDate: new Date(1970, 0, 1),
      maxDate: new Date(2089, 12, 1),
      radioData: "",
      formData: {
        CQRHSYRXM: "",
        // CQRHSYR:'',
        CQRHSYRZJHM: "",
        CQRHSYRZJDH: "",
        XMHZJGMC: "",
        JZMC: "",
        // SSHYXT:'',
        CQXZ: "",
        CQRHSYRZJLX: "",
        SEATNAME: "",
        XXDZ: "",
        isFourImport: "",
        // fourImportType:'',
        TDXZ: "",
        JCSJ: "",
        JZCS: "",
        DXCS: "",
        DSCS: "",
        JZMJ: "",
        JGLX: "",
        isAtlas: "",
        SFGZ: "",
        GZFS: "",
        isJD: "",
        JDDJ: "",
        JZYT: "",
        hasTicket: "",
        TicketNumber: "",
        // houseSideType:'',
      },
      formHZXX: {
        hZXM: "", // 户主姓名
        hZSFZH: "", // 户主身份证号
        hZDH: "", // 户主电话
        zP_FWBH: "",
        fW_ADDRESS: "",
        fW_CITYCODE: "",
      },
      showPicker: false,
      showPickerq: false,
      showPickerq1: false,
      ISYYZZ: false,
      IsShowAre: false,
      columnsJGLX: [],
      showPickerJGLX: false,
      showPickerCQXZ: false,
      showPickerSSHYXT: false,
      columnsSSHYXT: [],
      columnsCQXZ: [
        {
          DICNAME: "个人",
          DICID: "0",
        },
        {
          DICNAME: "村集体",
          DICID: "1",
        },
        {
          DICNAME: "政府",
          DICID: "2",
        },
        {
          DICNAME: "国有企业",
          DICID: "3",
        },
        {
          DICNAME: "民营企业",
          DICID: "4",
        },
        {
          DICNAME: "其他",
          DICID: "5",
        },
      ],
      contentData: [
        {
          name: "建筑周边环境",
          children: [
            {
              name: "无异常",
              key: "build_is_error",
              value: "",
            },
            {
              name: "房屋周边地面长期积水",
              key: "build_is_water",
              value: "",
            },
            {
              name: "房屋上装有大型广告牌",
              key: "build_is_billboard",
              value: "",
            },
            {
              name: "房屋周边有工程建设和深基坑 施工情况",
              key: "build_is_roadwork",
              value: "",
            },
            {
              name: "房屋周边有影响安全的危险因素(例如山体滑坡等)",
              key: "build_is_danger",
              value: "",
            },
            // {
            //   name: '有未经设计擅自加层的情况',
            //   key:'build_is_addfloor',
            //   value: ''
            // },
            {
              name: "有破墙开门、开窗或开店等影响结构安全的行为，或其他改变使用功能有较大变动情况",
              key: "build_is_structure",
              value: "",
            },
          ],
          fileData: [
            {
              name: "房屋及周边整体照片",
              groupGuid: "1",
              fileList: [],
            },
          ],
        },
        {
          name: "地基基础",
          children: [
            {
              name: "无异常",
              key: "base_is_error",
              value: "1",
            },
            {
              name: "房屋出现明显不均匀沉降（斜向） 裂缝",
              key: "base_is_crack",
              value: "1",
              fileData: [
                {
                  name: "房屋整体照片",
                  groupGuid: "2",
                  fileList: [],
                },
              ],
            },

            {
              name: "外露基础明显腐蚀、酥碱、松散 和剥落",
              key: "base_is_age",
              value: "1",
            },
            {
              name: "裂缝持续发展尚未稳定",
              key: "base_is_crack_continue",
              value: "1",
            },
            {
              name: "出现明显倾斜",
              key: "base_is_angle",
              value: "1",
            },
            {
              name: "基础局部或整体塌陷",
              key: "base_is_subside",
              value: "1",
            },
          ],
          fileData: [
            {
              name: "房屋整体照片",
              groupGuid: "3",
              fileList: [],
            },
          ],
        },
        {
          name: "楼屋面",
          children: [
            {
              name: "楼屋面",
              key: "house_type",
              active: false,
              type: "select",
              ARR: [
                {
                  DICNAME: "空心板",
                  DICID: "0",
                },
                {
                  DICNAME: "瓦屋面",
                  DICID: "1",
                },
                {
                  DICNAME: "现浇",
                  DICID: "2",
                },
                {
                  DICNAME: "其他",
                  DICID: "3",
                },
              ],
            },
            {
              // name: '类型',
              type: "Checkbox",
              // key:'house_is_error',
              children: [
                {
                  name: "无异常",
                  key: "house_is_error",
                },
                {
                  name: "明显变形",
                  key: "house_is_transform",
                },
                {
                  name: "明显裂缝",
                  key: "house_is_crack",
                },
                {
                  name: "较严重渗漏",
                  key: "house_is_leak",
                },
                {
                  name: "老化破损",
                  key: "house_is_age",
                },
              ],
              disabled:false
            },
          ],
          fileData: [
            {
              name: "楼屋面照片",
              groupGuid: "4",
              fileList: [],
            },
          ],
        },
        {
          name: "现场检查",
          disabled:false,
          children: [
            {
              name: "建筑结构",
              type: "select",
              key: "live_structer_type",
              active: false,
              value: "",
              ARR: [
                {
                  DICNAME: "砖砌墙",
                  DICID: "0",
                },
                {
                  DICNAME: "石砌墙",
                  DICID: "1",
                },
                {
                  DICNAME: "生土墙体",
                  DICID: "2",
                },
                {
                  DICNAME: "承重木构架",
                  DICID: "3",
                },
                {
                  DICNAME: "梁柱混凝土构件",
                  DICID: "4",
                },
                {
                  DICNAME: "楼板混凝土构件",
                  DICID: "5",
                },
                {
                  DICNAME: "其他情况",
                  DICID: "6",
                },
              ],
            },
            {
              name: "无异常",
              key: "live_brick_is_error",
              value: "1",
            },
            {
              name: "墙体普遍开裂，剥蚀严重",
              key: "live_brick_is_age",
              value: "1",
            },
            {
              name: "纵横墙体交接处竖向开裂",
              key: "live_brick_is_crack",
              value: "1",
            },
            {
              name: "墙体有歪斜",
              key: "live_brick_is_angle",
              value: "1",
            },
            {
              name: "局部倒塌或有倒塌危险",
              key: "live_brick_is_subside",
              value: "1",
            },
            {
              name: "使用小型混凝土空心砌块",
              key: "live_brick_is_air_brick",
              value: "1",
            },
            {
              name: "受潮渗漏",
              key: "live_brick_is_leak",
              value: "1",
            },
          ],
          fileData: [
            {
              name: "房屋东面、西面、北面、南面照片",
              groupGuid: "5",
              fileList: [],
            },
          ],
        },
        {
          name: "现场检查结果",
          children: [
            {
              name: "安全隐患初判",
              type: "select",
              active: false,
              key: "check_first_result",
              value: "",
              ARR: [
                {
                  DICNAME: "存在风险",
                  DICID: "0",
                },
                {
                  DICNAME: "基本安全",
                  DICID: "1",
                },
              ],
            },
            {
              name: "文字",
              type: "text",
              key: "check_first_result",
              value: "当房屋无以上情况且处于正常使用情况下，可继续正常使用",
              value1:
                "当存在以上一条或多条状况时，初判存在危险，房屋应进行鉴定，并根据鉴定结论分类处置",
            },
          ],
        },
      ],
      formDataPC: {
        CREATE_USER: "",
        pcsj: "",
        farmhouse_type: "0",
        build_is_addfloor: "",
        build_is_water: "",
        build_is_billboard: "",
        build_is_roadwork: "",
        build_is_danger: "",
        build_is_structure: "",
        base_is_crack: "",
        check_first_result: "",
        build_is_error: "",
        base_is_error: "",
        base_is_age: "",
        base_is_crack_continue: "",
        base_is_angle: "",
        base_is_subside: "",
        house_is_error: "",
        house_type: "0",
        live_is_error: "",
        live_is_age: "",
        live_is_crack: "",
        live_is_angle: "",
        live_is_subside: "",
        live_is_air_brick: "",
        live_is_leak: "",
        live_beton_is_age: "",
        live_beton_is_angle: "",
        live_beton_is_crack: "",
        live_beton_is_error: "",
        live_brick_is_age: "",
        live_brick_is_air_brick: "",
        live_brick_is_angle: "",
        live_brick_is_crack: "",
        live_brick_is_error: "",
        live_brick_is_leak: "",
        live_brick_is_subside: "",
        live_other_is_error: "",
        live_other_question: "",
        live_picture: "",
        live_soil_is_age: "",
        live_soil_is_angle: "",
        live_soil_is_crack: "",
        live_soil_is_error: "",
        live_soil_is_leak: "",
        live_soil_is_subside: "",
        live_soil_is_vertical_crack: "",
        live_stone_is_angle: "",
        live_stone_is_bad: "",
        live_stone_is_crack: "",
        live_stone_is_error: "",
        live_stone_is_subside: "",
        live_structer_type: "0",
        live_wood_is_age: "",
        live_wood_is_air_dried: "",
        live_wood_is_angle: "",
        live_wood_is_crack: "",
        live_wood_is_error: "",
        live_wood_is_link: "",
        live_wood_is_pool: "",
        live_wood_is_rip: "",
        live_wood_is_subside: "",
      },
      ENUM: {
        FWLXARR: [
          {
            DICNAME: "自建房",
            DICID: "0",
          },
          {
            DICNAME: "非自建房",
            DICID: "1",
          },
        ],
        showPickerFWLX: false,
      },
      columnsZJLX: [],
      isSave: false,
      JZJG: [
        {
          name: "砖砌墙",
          DICID: "0",
          children: [
            {
              name: "无异常",
              key: "live_brick_is_error",
              value: "1",
            },
            {
              name: "墙体普遍开裂，剥蚀严重",
              key: "live_brick_is_age",
              value: "1",
            },
            {
              name: "纵横墙体交接处竖向开裂",
              key: "live_brick_is_crack",
              value: "1",
            },
            {
              name: "墙体有歪斜",
              key: "live_brick_is_angle",
              value: "1",
            },
            {
              name: "局部倒塌或有倒塌危险",
              key: "live_brick_is_subside",
              value: "1",
            },
            {
              name: "使用小型混凝土空心砌块",
              key: "live_brick_is_air_brick",
              value: "1",
            },
            {
              name: "受潮渗漏",
              key: "live_brick_is_leak",
              value: "1",
            },
          ],
        },
        {
          name: "石砌墙",
          DICID: "1",
          children: [
            {
              name: "无异常",
              key: "live_stone_is_error",
              value: "1",
            },
            {
              name: "墙体普遍开裂或开裂严重，明显空鼓，部分石料松动",
              key: "live_stone_is_crack",
              value: "1",
            },
            {
              name: "纵横墙体交接处竖向开裂，墙体有歪斜",
              key: "live_stone_is_angle",
              value: "1",
            },
            {
              name: "局部倒塌或有倒塌危险",
              key: "live_stone_is_subside",
              value: "1",
            },
            {
              name: "墙体采用乱毛石、鹅卵石砌筑，或砌筑砂浆为泥浆或无浆干砌的",
              key: "live_stone_is_bad",
              value: "1",
            },
          ],
        },
        {
          name: "生土墙体",
          DICID: "2",
          children: [
            {
              name: "无异常",
              key: "live_soil_is_error",
              value: "1",
            },
            {
              name: "墙体开裂严重",
              key: "live_soil_is_crack",
              value: "1",
            },
            {
              name: "墙面明显剥蚀、空鼓严重",
              key: "live_soil_is_age",
              value: "1",
            },
            {
              name: "纵横墙体交接处竖向开裂",
              key: "live_soil_is_vertical_crack",
              value: "1",
            },
            {
              name: "墙体有歪斜",
              key: "live_soil_is_angle",
              value: "1",
            },
            {
              name: "局部倒塌或有倒塌危险",
              key: "live_soil_is_subside",
              value: "1",
            },
            {
              name: "处于长期受潮状态或周边排水不畅的生土墙体",
              key: "live_soil_is_leak",
              value: "1",
            },
          ],
        },
        {
          name: "承重木构架",
          DICID: "3",
          children: [
            {
              name: "无异常",
              key: "live_wood_is_error",
              value: "1",
            },
            {
              name: "明显腐朽或虫蛀",
              key: "live_wood_is_age",
              value: "1",
            },
            {
              name: "梁、檩跨中明显变形或出现横向裂缝",
              key: "live_wood_is_crack",
              value: "1",
            },
            {
              name: "梁、檩端部出现劈裂",
              key: "live_wood_is_rip",
              value: "1",
            },
            {
              name: "柱身明显歪斜",
              key: "live_wood_is_angle",
              value: "1",
            },
            {
              name: "木柱与柱基础之间错位",
              key: "live_wood_is_subside",
              value: "1",
            },
            {
              name: "构件纵向有明显干缩裂缝",
              key: "live_wood_is_air_dried",
              value: "1",
            },
            {
              name: "卯榫节点有破损或有拔榫迹象",
              key: "live_wood_is_pool",
              value: "1",
            },
            {
              name: "承重柱存在接柱或转换情况且未采取可靠连接措施",
              key: "live_wood_is_link",
              value: "1",
            },
          ],
        },
        {
          name: "梁柱混凝土构件",
          DICID: "4",
          children: [
            {
              name: "无异常",
              key: "live_beton_is_error",
              value: "1",
            },
            {
              name: "保护层剥落严重",
              key: "live_beton_is_age",
              value: "1",
            },
            {
              name: "钢筋露筋、锈蚀，出现明显锈胀裂缝",
              key: "live_beton_is_crack",
              value: "1",
            },
            {
              name: "梁柱出现明显受力裂缝和变形",
              key: "live_beton_is_angle",
              value: "1",
            },
          ],
        },
        {
          name: "楼板混凝土构件",
          DICID: "5",
          children: [
            {
              name: "无异常",
              key: "live_beton_is_error",
              value: "1",
            },
            {
              name: "保护层剥落严重",
              key: "live_beton_is_age",
              value: "1",
            },
            {
              name: "钢筋露筋、锈蚀，出现明显锈胀裂缝",
              key: "live_beton_is_crack",
              value: "1",
            },
            {
              name: "楼板出现明显受力裂缝和变形。",
              key: "live_beton_is_angle",
              value: "1",
            },
          ],
        },
        {
          name: "其他情况",
          DICID: "6",
          children: [
            {
              name: "其他存在危险性的情况",
              type: "input",
              key: "live_other_question",
              value: "1",
              required: true,
            },
          ],
        },
      ],
    };
  },
  filters: {
    inUseName: function (msg, data) {
      let name = "";
      if (data && msg) {
        data.forEach((item) => {
          if (item.DICID == msg) {
            name = item.DICNAME;
          }
        });
      }
      return name;
    },
  },
  methods: {
    validator(val) {
      var idcardReg =
        /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
      return idcardReg.test(val);
    },
    // 格式化日期
    dateFormat(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      let time = `${year}-${month}-${day}`;
      return time;
    },
    closeA() {
      this.IsShowAre = false;
    },
    handleGoMap() {
      let me = this;
      if (this.FWTYBH) {
        //浙政钉
        dd.ready(function () {
          dd.openLink({
            url: `https://nfzjszlb.jst.zj.gov.cn/webserver/surveyMap/index.html?FWTYBH=${me.FWTYBH}&Address=${me.formData.SEATNAME}`,
          })
            .then((res) => {
            })
            .catch((err) => {
              window.open(
                `https://nfzjszlb.jst.zj.gov.cn/webserver/surveyMap/index.html?FWTYBH=${me.FWTYBH}&Address=${me.formData.SEATNAME}`
              );
            });
        });
      } else {
        this.$toast.fail("缺少房屋编号!");
      }
    },
    onChange({ value, selectedOptions, tabIndex }) {
      try {
        if (selectedOptions[tabIndex].children.length == 0 && tabIndex < 2) {
          this.getXZQH(value, selectedOptions, tabIndex);
        }
      } catch (err) {}
      this.onFinish({ value, selectedOptions, tabIndex });
    },
    handleClick1(data) {
      if (data == "是否有营业执照") {
        //判断当前选择的是还是否 隐藏编号
        this.ISYYZZ = true;
      } else {
        this.ISYYZZ = false;
      }
    },
    onFinish({ value, selectedOptions, tabIndex }) {
      //汉字
      this.formData[this.FWJCXXData[0].key] = selectedOptions
        .map((option) => option.text)
        .join("");
      this.$set(
        this.formData,
        "SEATNAME",
        this.formData[this.FWJCXXData[0].key]
      );
      this.formHZXX.fW_ADDRESS = this.formData[this.FWJCXXData[0].key];
      //code
      this.areaCode = selectedOptions.map((option) => option.value);
      // this.areaCode.length == 3 ? (this.IsShowAre = false) : "";
      window.localStorage.setItem(
        "citycode2",
        this.areaCode[this.areaCode.length - 1]
      );
      if (this.areaCode.length == 1) {
        this.getNFFM("");
      } else if (this.areaCode.length == 2) {
        this.getNFFM("F_CITY", this.areaCode[this.areaCode.length - 1]);
      }
      if (tabIndex == 2) {
        this.closeA();
      }
    },
    // select 确定
    onConfirm(val) {
      this.showPickerq = false;
      this.formDataPC.pcsj = this.dateFormat(val);
    },
    onConfirmSJ(val) {
      this.FWJCXXData.forEach((item, index) => {
        if (item.active) {
          this.formData[item.key] = this.dateFormat(val);
          item.active = false;
        }
      });
    },
    getXZQH: async function (value, selectedOptions, tabIndex) {
      var res = await GetAdministrative(value);
      selectedOptions[tabIndex].children = [];
      if (res.data.data.length > 0) {
        res.data.data.forEach((element) => {
          let obj = {
            text: element.cityname,
            value: element.citycode,
          };
          if (tabIndex < 1) {
            obj["children"] = [];
          }
          selectedOptions[tabIndex].children.push(obj);
        });
      }
    },
    getNFFM: async function (field, code) {
      let params = {
        dataguid: "09da1684-766d-4779-8403-bbd31fa7eb6d",
        searchObject: [],
        token: window.localStorage.getItem("token"),
      };
      this.NFFMData = [];
      if (code && field) {
        params.searchObject = JSON.stringify([
          { field: field, operator: "like", value: code, link: "AND" },
        ]);
      }
      var res = await LoadGridData(params);
      this.NFFMData = res.data.Data;
    },
    onConfirm1(val) {
      this.showPicker = false;
      this.form.FWLX = val;
    },
    onConfirmJGLX(val) {
      this.formData.CQRHSYRZJLX = val.DICID;
      this.showPickerJGLX = false;
    },
    onConfirmCQXZ(val) {
      this.formData.CQXZ = val.DICID;
      this.showPickerCQXZ = false;
    },
    onConfirmSSHYXT(val) {
      this.formData.SSHYXT = val.DICID;
      this.ENUM.showPickerSSHYXT = false;
    },
    // 保存
    saveData: async function () {
      let formBT = true;
      this.formHZXX.fW_CITYCODE = window.localStorage.getItem("citycode2");
      if (!this.formHZXX.fW_ADDRESS) {
        this.formHZXX.fW_ADDRESS = this.formData[this.FWJCXXData[0].key];
      }
      for (let i in this.formHZXX) {
        if (i !== "fW_CITYCODE" && i !== "fW_ADDRESS" && i !== "hZDH") {
          if (this.formHZXX[i] == "") {
            this.$toast.fail("请填写灾普信息必填项!");
            formBT = false;
          }
        }
      }
      this.contentData.forEach((item, index) => {
        if (item.fileData) {
          item.fileData.forEach((item1, index) => {
            if (item1.name == "房屋整体照片" && item1.fileList.length == 0) {
              this.$toast.fail("请上传房屋整体照片!");
              formBT = false;
            }
          });
        }
      });
      if (formBT) {
        //todo
        this.formData.SEATID = window.localStorage.getItem("citycode2");
        this.formDataPC.fwid = this.fwIdData;
        let params = {
          // 排查信息
          houseCheckDto: this.formDataPC,
          houseInfo: this.formHZXX,
          // // 自建房
          // fwInfo:{},
          // // 非自建房
          // fzjfwInfo:{}
        };
        // if (this.isZJ) {
        //   params.fwInfo = this.formData
        //   if (this.isFWLX){
        //     params.fwInfo.isnew = "1"
        //   }else{
        //     params.fwInfo.isnew = "0"
        //   }
        // }else{
        //   params.fzjfwInfo = this.formData
        //   if (this.isFWLX){
        //     params.fzjfwInfo.isnew = "1"
        //   }else{
        //     params.fzjfwInfo.isnew = "0"
        //   }
        // }
        const res1 = await saveOrUpdate(params);
        if (res1.data.success) {
          this.FWTYBH = res1.data.data.FWTYBH;
          this.$toast.success("保存成功!");
          this.isSave = true;
        } else {
          this.$toast.fail("保存失败!");
        }
      }
    },
    guid() {
      return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
        /[xy]/g,
        function (c) {
          var r = (Math.random() * 16) | 0,
            v = c == "x" ? r : (r & 0x3) | 0x8;
          return v.toString(16);
        }
      );
    },
    getEnum: async function (viewID, name) {
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          dataguid: viewID,
          searchObject: JSON.stringify([]),
          token: window.localStorage.getItem("token"),
        },
      };
      const res = await FileServerProxy(params);
      switch (viewID) {
        case "b19e6f27-f574-4dea-9490-f7798ab7331a":
          this.ENUM.FWLXARR = JSON.parse(res.data.data).Data;
          break;
        // case "97748eea-9abd-4ec2-97f6-0358f1597a1f":
        //   this.columnsZJLX = JSON.parse(res.data.data).Data;
        //   break;
        default:
          if (
            name == "楼屋面" ||
            name == "建筑结构" ||
            name == "安全隐患初判"
          ) {
            this.contentData.forEach((item, index) => {
              item.children.forEach((item1, index1) => {
                if (item1.name == name) {
                  item1.ARR = JSON.parse(res.data.data).Data;
                }
              });
            });
          } else {
            this.FWJCXXData.forEach((item, index) => {
              if (item.name == name) {
                item.ARR = JSON.parse(res.data.data).Data;
              }
            });
          }
          break;
      }
    },
    getYearsToNow() {
      this.FWJCXXData[4].ARR = [];
      // this.yearsToNow=[2020,2021,2022]
      //获取到从那一年开始
      let smallYears = 1970;
      //获取当前时间
      let date = new Date();
      let nowYears = date.getFullYear();
      let Years = nowYears - smallYears;
      let arrYear = [];
      for (let i = 0; i <= Years; i++) {
        arrYear.push(nowYears--);
      }
      arrYear.forEach((item) => {
        //下拉框的数组
        this.FWJCXXData[4].ARR.push({
          DICNAME: item,
          DICID: item,
        });
      });
    },
    getEnumeration1() {
      if (this.isZJ) {
        this.columnsZJLX = [
          {
            DICNAME: "身份证",
            DICID: "0",
          },
          {
            DICNAME: "护照",
            DICID: "1",
          },
          {
            DICNAME: "港澳台身份证明",
            DICID: "2",
          },
        ];
        // this.getEnum("b6c676b3-870b-43c1-91b5-fccb7513a7b9",'土地性质')
        // this.getEnum("312fc099-4ecd-4c1d-823a-75c66e8beb0f",'证件类型')
      } else {
        this.columnsZJLX = [
          {
            DICNAME: "身份证",
            DICID: "0",
          },
          {
            DICNAME: "护照",
            DICID: "1",
          },
          {
            DICNAME: "港澳台身份证明",
            DICID: "2",
          },
          {
            DICNAME: "机构代码",
            DICID: "3",
          },
        ];
        // this.getEnum("be0caa2a-d920-4987-acf7-94a5d2fc0585",'土地性质')
        // this.getEnum("97748eea-9abd-4ec2-97f6-0358f1597a1f",'证件类型')
      }
    },
    onConfirmFWLX(val) {
      this.formDataPC.farmhouse_type = val.DICID;
      this.ENUM.showPickerFWLX = false;
      if (val.DICID == "0") {
        this.isZJ = true;
      } else {
        this.isZJ = false;
      }
      this.getEnumeration1();
    },
    onConfirmALL(val) {
      // try{
      //   if(val.DICNAME == '未改造'){
      //     this.FWJCXXData.forEach((item,index)=>{
      //       if(item.name == '改造方式'){
      //         // this.FWJCXXData.splice(index,1)
      //       }
      //     })
      //   }else if(val.DICNAME == '有改造'){
      //      this.FWJCXXData.forEach((item,index)=>{
      //       if(item.name == '改造情况'&&this.FWJCXXData[index+1].name!='改造方式'){
      //         this.FWJCXXData.splice(index+1,0,{
      //             name:'改造方式',
      //             key:'GZFS',
      //             type:'select',
      //             active:false,
      //             required:true,
      //             ARR:[
      //               {
      //                 DICNAME:"楼顶加层",
      //                 DICID:"0"
      //               },
      //               {
      //                 DICNAME:"周边扩建",
      //                 DICID:"1"
      //               },
      //               {
      //                 DICNAME:"楼内夹层",
      //                 DICID:"2"
      //               },
      //               {
      //                 DICNAME:"改变承重结构",
      //                 DICID:"3"
      //               },
      //               {
      //                 DICNAME:"下挖",
      //                 DICID:"4"
      //               },
      //               {
      //                 DICNAME:"其他",
      //                 DICID:"5"
      //               }
      //             ]
      //         })
      //       }
      //     })
      //   }
      // }catch(err){
      //
      // }
      try {
        if (val.DICNAME == "未鉴定") {
          //隐藏鉴定等级
          this.FWJCXXData.forEach((item, index) => {
            if (item.name == "鉴定等级") {
              this.FWJCXXData.splice(index, 1);
            }
          });
          // if(this.FWJCXXData[14].name=='鉴定等级'){
          //   this.FWJCXXData.splice(14,1)
          // }
        } else if (val.DICNAME == "已鉴定") {
          this.FWJCXXData.forEach((item, index) => {
            if (
              item.name == "鉴定情况" &&
              this.FWJCXXData[index + 1].name != "鉴定等级"
            ) {
              this.FWJCXXData.splice(index + 1, 0, {
                name: "鉴定等级",
                key: "JDDJ",
                type: "select",
                active: false,
                required: true,
                ARR: [
                  {
                    DICNAME: "A级",
                    DICID: "0",
                  },
                  {
                    DICNAME: "B级",
                    DICID: "1",
                  },
                  {
                    DICNAME: "C级",
                    DICID: "2",
                  },
                  {
                    DICNAME: "D级",
                    DICID: "3",
                  },
                ],
              });
            }
          });
        }
      } catch (err) {}
      try {
        if (val.DICNAME == "否" && this.ISYYZZ) {
          try {
            if (this.FWJCXXData[17].name == "营业执照编号") {
              this.FWJCXXData.splice(17, 1);
            }
          } catch (err) {}
          try {
            if (this.FWJCXXData[16].name == "营业执照编号") {
              this.FWJCXXData.splice(16, 1);
            }
          } catch (ERR) {}
          if (this.FWJCXXData[15].name == "营业执照编号") {
            this.FWJCXXData.splice(15, 1);
          }
        } else if (val.DICNAME == "是" && this.ISYYZZ) {
          let index = 0;
          this.FWJCXXData.forEach((item) => {
            if (item.name == "营业执照编号") {
              index += 1;
            }
          });
          if (index == 0) {
            this.FWJCXXData.splice(17, 0, {
              name: "营业执照编号",
              key: "TicketNumber",
              type: "input",
              required: true,
              placeholder: "请输入营业执照编号",
            });
          }
        }
      } catch (err) {}
      this.FWJCXXData.forEach((item, index) => {
        if (item.active) {
          this.formData[item.key] = val.DICID;
          item.active = false;
        }
        if (item.name == "改造情况" && this.formData[item.key] == "0") {
          this.FWJCXXData[index + 1].type = false;
        }
        if (item.name == "改造情况" && this.formData[item.key] == "1") {
          this.FWJCXXData[index + 1].type = "select";
        }
      });
    },
    handleClick(data) {
      // if(data.name == '房屋地址'){
      if (this.isAdd){
        this.IsShowAre = true;
      }

      // }
    },
    onConfirmContent(val) {
      this.DICNAME = val.DICID;
      this.contentData.forEach((item, index) => {
        item.children.forEach((item1, index1) => {
          if (item1.active) {
            this.formDataPC[item1.key] = val.DICID;
            item1.active = false;
          }
          // if (item1.type=='Checkbox'){
          //   item1.disabled = true
          //   this.$forceUpdate()
          // }
          if (item1.name === "建筑结构") {
            // if (this.formDataPC.live_structer_type){
            //   this.disabled = false
            // }
            this.JZJG.forEach((item2, index2) => {
              if (item2.name === val.DICNAME) {
                item.children.splice(1, item.children.length - 1);
                item2.children.forEach((item3) => {
                  item.children.push(item3);
                });
              }
            });
          }
        });
      });
    },
    getList(item) {
      this.groupGuids = item.groupGuid;
    },
    afterRead(file) {
      this.getFileServerUpload(file.file);
    },
    getFileServerUpload: async function (file) {
      let data = {
        toRowGuid: this.fwIdData,
        groupGuid: this.groupGuids,
        token: window.localStorage.getItem("token"),
      };
      let formData = new FormData();
      formData.append("file", file);
      formData.append("accessCode", "7a3fc061c866434b8475d3775c9ddcea");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append("token", window.localStorage.getItem("token"));
      formData.append("paramStr", JSON.stringify(data));
      const res = await dataTransFile(formData);
      let data1 = JSON.parse(res.data.data).FileList;
      this.fileGuid = data1[0].FILEGUID;
      if (data1[0].FILEGUID) {
        this.$toast.success("上传成功!");
      }
    },
    delectFile: async function (file) {
      let fileguid = "";
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID;
      } else {
        fileguid = this.fileGuid;
      }
      if (fileguid) {
        let params = {
          accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem("token"),
          },
        };
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data) {
          this.$toast.success("删除成功!");
        }
      }
    },
    getData: async function (data, type) {
      this.isData = true;
      let params = "fwId=" + data;
      const res = await houseCheckDetail(params);
      // // 房屋信息
      // if (res.data.houseBaseInfo){
      //   for (let i in this.formData){
      //     if(res.data.houseBaseInfo[i]!="" && res.data.houseBaseInfo[i]!=null || res.data.houseBaseInfo[i]==0){
      //       this.formData[i] = res.data.houseBaseInfo[i].toString()
      //     }
      //     if(i == 'isJD' && res.data.houseBaseInfo[i]!=null){
      //       if(res.data.houseBaseInfo[i] == 0){
      //         this.FWJCXXData.splice(14,1)
      //       }
      //     }
      //     if(i == 'hasTicket'&&res.data.houseBaseInfo[i]!=null){
      //       if(res.data.houseBaseInfo[i] == 1){
      //         this.FWJCXXData.splice(17,1)
      //       }
      //     }
      //   }
      //   //
      //   if (this.formData.JDDJ){
      //     this.formData.isJD = "1"
      //   }
      //   // this.formData = res.data.houseBaseInfo
      // }
      // 户主信息
      if (res.data.houseInfo) {
        for (let i in this.formHZXX) {
          // if (res.data.houseInfo[i]){
          this.formHZXX[i] = res.data.houseInfo[i];
          // }
        }
      }
      // 排查信息
      if (res.data.checkInfo) {
        for (let i in this.formDataPC) {
          if (
            (res.data.checkInfo[i.toUpperCase()] != "" &&
              res.data.checkInfo[i.toUpperCase()] != null) ||
            res.data.checkInfo[i.toUpperCase()] == 0
          ) {
            this.formDataPC[i] = res.data.checkInfo[i.toUpperCase()].toString();
          }
        }
        // LIVE_STRUCTER_TYPE
        if (
          res.data.checkInfo.LIVE_STRUCTER_TYPE !== "" &&
          res.data.checkInfo.LIVE_STRUCTER_TYPE !== null
        ) {
          this.DICNAME = res.data.checkInfo.LIVE_STRUCTER_TYPE.toString();
        }
        if (res.data.checkInfo.HOUSE_IS_ERROR == 0) {
          this.radioData = "无异常";
        } else if (res.data.checkInfo.HOUSE_IS_TRANSFORM == 0) {
          this.radioData = "明显变形";
        } else if (res.data.checkInfo.HOUSE_IS_LEAK == 0) {
          this.radioData = "较严重渗漏";
        } else if (res.data.checkInfo.HOUSE_IS_CRACK == 0) {
          this.radioData = "明显裂缝";
        } else if (res.data.checkInfo.HOUSE_IS_AGE == 0) {
          this.radioData = "老化破损";
        }
        this.contentData.forEach((item, index) => {
          item.children.forEach((item1, index1) => {
            if (item1.name === "建筑结构") {
              item.children.splice(1, item.children.length - 1);
              this.JZJG.forEach((item2, index2) => {
                if (item2.DICID == res.data.checkInfo.LIVE_STRUCTER_TYPE) {
                  item2.children.forEach((item3) => {
                    item.children.push(item3);
                  });
                }
              });
            }
          });
        });
      }
      // this.FWTYBH = res.data.houseBaseInfo.FWTYBH
      this.formDataPC.pcsj = this.formDataPC.pcsj.substring(0, 10);
      this.FWJCXXData.forEach((item, index) => {
        if (item.name == "改造情况" && this.formData[item.key] == "0") {
          this.FWJCXXData[index + 1].type = false;
        }
        if (item.name == "改造情况" && this.formData[item.key] == "1") {
          this.FWJCXXData[index + 1].type = "select";
        }
        if (item.name == "是否有营业执照" && this.formData[item.key] == "1") {
          this.FWJCXXData[index + 1].type = false;
        }
        if (item.name == "是否有营业执照" && this.formData[item.key] == "0") {
          this.FWJCXXData[index + 1].type = "input";
        }
      });
    },
    radioChange(data) {
      switch (data) {
        case "无异常":
          this.formDataPC.house_is_error = "0";
          this.formDataPC.house_is_transform = "1";
          this.formDataPC.house_is_leak = "1";
          this.formDataPC.house_is_crack = "1";
          this.formDataPC.house_is_age = "1";
          break;
        case "明显变形":
          this.formDataPC.house_is_transform = "0";
          this.formDataPC.house_is_error = "1";
          this.formDataPC.house_is_leak = "1";
          this.formDataPC.house_is_crack = "1";
          this.formDataPC.house_is_age = "1";
          break;
        case "明显裂缝":
          this.formDataPC.house_is_leak = "1";
          this.formDataPC.house_is_transform = "1";
          this.formDataPC.house_is_error = "1";
          this.formDataPC.house_is_crack = "0";
          this.formDataPC.house_is_age = "1";
          break;
        case "较严重渗漏":
          this.formDataPC.house_is_crack = "1";
          this.formDataPC.house_is_error = "1";
          this.formDataPC.house_is_transform = "1";
          this.formDataPC.house_is_leak = "0";
          this.formDataPC.house_is_age = "1";
          break;
        case "老化破损":
          this.formDataPC.house_is_age = "0";
          this.formDataPC.house_is_error = "1";
          this.formDataPC.house_is_transform = "1";
          this.formDataPC.house_is_leak = "1";
          this.formDataPC.house_is_crack = "1";
          break;
      }
      let arr = [];
      for (let i in this.formDataPC) {
        if (
          i != "build_is_error" &&
          i != "base_is_error" &&
          i != "house_is_error" &&
          i != "live_is_error" &&
          i != "live_soil_is_error" &&
          i != "live_stone_is_error" &&
          i != "live_wood_is_error" &&
          i != "live_beton_is_error" &&
          i != "live_brick_is_error" &&
          i != "check_first_result" &&
          i != "farmhouse_type" &&
          i != "live_structer_type" &&
          i != "house_type"
        ) {
          if (this.formDataPC[i] == "0") {
            arr.push(this.formDataPC[i]);
          }
        }
      }
      if (arr.indexOf("0") !== -1 || data !== "无异常") {
        this.formDataPC.check_first_result = "0";
      } else {
        this.formDataPC.check_first_result = "1";
      }
    },
    initializeCode() {
      this.formDataPC.CREATE_USER = JSON.parse(
        window.localStorage.getItem("userName")
      ).userName;
      this.formDataPC.pcsj = this.getDate(true);
    },
    IDdesensitization(data) {
      if (data) {
        let id = data.replace(/^(.{6})(?:d+)(.{4})$/, "$1****$2");
        return id;
      }
    },
    //潘提供的方法
    handleMapUpdate() {
      ;
      // 房屋编号
      var fwbh = this.FWTYBH;
      // 修改排查状态 (未排查/排查中/已排查/已取消)
      var newZT = "排查中";
      var serverUrl = "";
      var fwbhKeyName = "";
      let serverIndex = this.isZJ ? 0 : 1;
      if (this.isZJ) {
        serverUrl =
          "https://nfzjszlb.jst.zj.gov.cn/tyzcpt/api/gisrest/arcgis/featurelayer/nlpc_sde.nlpc.t_fw";
        fwbhKeyName = "FWTYBH";
      } else {
        serverUrl =
          "https://nfzjszlb.jst.zj.gov.cn/tyzcpt/api/gisrest/arcgis/featurelayer/nlpc_sde.nlpc.t_fzjfw";
        fwbhKeyName = "fwid";
      }

      var parameters = {
        f: "json",
        outFields: "*",
        //returnGeometry: false,
        spatialRel: "esriSpatialRelIntersects",
        where: `${fwbhKeyName} = '${fwbh}'`,
      };
      axios
        .get(`${serverUrl}/query`, {
          params: parameters,
        })
        .then((response) => {
          console.info(response.data);
          if (response.data && response.data.features) {
            let feature = response.data.features[0];
            feature.attributes.PCZT = newZT;
            const featureStr = JSON.stringify([feature]);
            const parametersUpdate = new FormData();
            parametersUpdate.append("f", "json");
            parametersUpdate.append("updates", featureStr);
            axios({
              url: `${serverUrl}/${serverIndex}/applyEdits`,
              method: "post",
              data: parametersUpdate,
            })
              .then((responseUpdate) => {
                console.info(responseUpdate);
              })
              .catch((errorUpdate) => {
                console.error(errorUpdate);
              });
          }
        })
        .catch((error) => {
          console.error(error);
        });
    },
    updateData: async function () {
      let formBT = true;
      for (let i in this.formHZXX) {
        if (i !== "fW_CITYCODE" && i !== "fW_ADDRESS" && i !== "hZDH") {
          if (this.formHZXX[i] == "") {
            this.$toast.fail("请填写灾普信息必填项!");
            formBT = false;
          }
        }
      }
      this.contentData.forEach((item, index) => {
        if (item.fileData) {
          item.fileData.forEach((item1, index) => {
            if (item1.name == "房屋整体照片" && item1.fileList.length == 0) {
              this.$toast.fail("请上传房屋整体照片!");
              formBT = false;
            }
          });
        }
      });
      if (formBT) {
        //todo
        this.formData.SEATID = window.localStorage.getItem("citycode2");
        this.formHZXX.fW_CITYCODE = window.localStorage.getItem("citycode2");
        if (!this.formHZXX.fW_ADDRESS) {
          this.formHZXX.fW_ADDRESS = this.formData[this.FWJCXXData[0].key];
        }
        this.formDataPC.fwid = this.fwIdData;

        let params = {
          // 排查信息
          houseCheckDto: this.formDataPC,
          houseInfo: this.formHZXX,
          // // 自建房
          // fwInfo:{},
          // // 非自建房
          // fzjfwInfo:{}
        };
        // if (this.isZJ) {
        //   params.fwInfo = this.formData
        //   if (this.isFWLX){
        //     params.fwInfo.isnew = "1"
        //   }else{
        //     params.fwInfo.isnew = "0"
        //   }
        // }else{
        //   params.fzjfwInfo = this.formData
        //   if (this.isFWLX){
        //     params.fzjfwInfo.isnew = "1"
        //   }else{
        //     params.fzjfwInfo.isnew = "0"
        //   }
        // }
        const res1 = await saveOrUpdate(params);
        if (res1.data.success) {
          this.$toast.success("保存成功!");
          let data = {
            fwId: this.fwIdData,
            checkStatus: 1,
          };
          const res = await changePcztByFwId(data);
          //this.handleMapUpdate();
          this.$router.push({
            path: "/keyInvestigation",
            query: {
              data: this.$route.query.data1,
              cityCode: this.$route.query.cityCode1,
              cityCodeS: this.$route.query.cityCodeS,
              cityCodeSCODE: this.$route.query.citycode,
            },
          });
        } else {
          this.$toast.fail("保存失败!");
        }
      }
    },
    radioChangef(data, event) {
      if (data.name === "无异常") {
        // if (this.formDataPC[data.key]=="0"){
        //   this.contentData.forEach((item,index)=>{
        //     if (item.name == event.name){
        //       item.children.forEach((item1,index)=>{
        //         if (item1.key !== data.key){
        //           this.formDataPC[item1.key] = "1"
        //         }
        //       })
        //     }
        //   })
        // }else{
        //   this.contentData.forEach((item,index)=>{
        //     if (item.name == event.name){
        //       item.children.forEach((item1,index)=>{
        //         if (item1.key !== data.key ){
        //           this.formDataPC[item1.key] = "2"
        //         }
        //       })
        //     }
        //   })
        // }
      } else {
        let arr = [];
        for (let i in this.formDataPC) {
          if (
            i != "build_is_error" &&
            i != "base_is_error" &&
            i != "house_is_error" &&
            i != "live_is_error" &&
            i != "live_soil_is_error" &&
            i != "live_stone_is_error" &&
            i != "live_wood_is_error" &&
            i != "live_beton_is_error" &&
            i != "live_brick_is_error" &&
            i != "check_first_result" &&
            i != "farmhouse_type" &&
            i != "live_structer_type" &&
            i != "house_type"
          ) {
            this.newformDataPC = "";
            if (this.formDataPC[i] == "0") {
              arr.push(this.formDataPC[i]);
            }
          }
        }
        if (arr.indexOf("0") !== -1) {
          this.formDataPC.check_first_result = "0";
        } else {
          this.formDataPC.check_first_result = "1";
        }
      }
      // if (this.rowData) {
      //   if (this.rowData.FWLX === "自建房") {
      //     this.formDataPC.farmhouse_type = "0";
      //   } else {
      //     this.formDataPC.farmhouse_type = "1";
      //   }
      // }
      // this.formDataPC.live_structer_type = this.DICNAME;
    },
    radioClick(data, event) {
      //
      if (data.name === "无异常") {
        if (this.formDataPC[data.key] == "0") {
          this.contentData.forEach((item, index) => {
            if (item.name == event.name) {
              item.children.forEach((item1, index) => {
                if (item1.key !== data.key) {
                  if(item1.key!=='live_structer_type'){
                    // alert(1)
                    this.formDataPC[item1.key] = "1";
                  }
                }
              });
            }
          });
        } else {
          this.contentData.forEach((item, index) => {
            if (item.name == event.name) {
              item.children.forEach((item1, index) => {
                if (item1.key !== data.key) {
                  this.formDataPC[item1.key] = "2";
                }
              });
            }
          });
        }
      } else {
        // if (this.formDataPC[data.key]=="0"){
        //   this.contentData.forEach((item,index)=>{
        //     if (item.name == "建筑周边环境"){
        //       item.children.forEach((item1,index)=>{
        //         if (item1.key == "build_is_error"){
        //           this.formDataPC[item1.key] = "1"
        //         }
        //       })
        //     }
        //     if (item.name == "地基基础"){
        //       item.children.forEach((item1,index)=>{
        //         if (item1.key == "base_is_error"){
        //           this.formDataPC[item1.key] = "1"
        //         }
        //       })
        //     }
        //     if (item.name == "现场检查"){
        //       item.children.forEach((item1,index)=>{
        //         switch (this.formDataPC.live_structer_type) {
        //           case '0':
        //             if (item1.key == "live_brick_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           case '1':
        //             if (item1.key == "live_stone_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           case '2':
        //             if (item1.key == "live_soil_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           case '3':
        //             if (item1.key == "live_wood_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           case '4':
        //             if (item1.key == "live_beton_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           case '5':
        //             if (item1.key == "live_beton_is_error"){
        //               this.formDataPC[item1.key] = "1"
        //             }
        //             break
        //           default:
        //             break
        //         }
        //       })
        //     }
        //   })
        // }
      }
    },
    getXianOpenDataView4: async function (data) {
      this.XianColumns = [];
      let dataGuid = "77fdf2b0-0eb5-4243-a0a4-6185299ccd34";
      let searchObject = JSON.stringify([
        { field: "pid", value: data, operator: "=" },
      ]);
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",

        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: {
          dataguid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      eval("(" + res.data.data + ")").Data.forEach((item) => {
        this.options.push({
          text: item.CITYNAME,
          value: item.CITYCODE,
          children: [],
        });
      });
    },
    getFile: async function () {
      let groupGuid = [];
      this.contentData.forEach((item) => {
        if (item.fileData) {
          item.fileData.forEach((item1) => {
            groupGuid.push(item1.groupGuid);
          });
        }
        item.children.forEach((item1) => {
          if (item1.fileData) {
            item1.fileData.forEach((item2) => {
              groupGuid.push(item2.groupGuid);
            });
          }
        });
      });
      let params = {
        accessCode: "1fdcbce42c6d4748a020feba618d54b8",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "",
        params: {
          groupGuid: groupGuid.join(","),
          toRowGuid: this.fwIdData,
          token: window.localStorage.getItem("token"),
        },
      };
      const res = await FileServerProxy(params);
      let data = JSON.parse(res.data.data).FilesInfo;
      if (data.length > 0) {
        data.forEach((element) => {
          this.contentData.forEach((item) => {
            if (item.fileData) {
              item.fileData.forEach((item1) => {
                if (element.GROUPGUID == item1.groupGuid) {
                  this.getFileUrl(element, item1);
                  // element["isImage"] = true;
                  // element["url"] =
                  //   window.g.BaseURL +
                  //   "FileServer/api/Preview?token=" +
                  //   window.localStorage.getItem("token") +
                  //   "&" +
                  //   "fileGuid=" +
                  //   encodeURIComponent(element.ROW_GUID);
                  // item1.fileList.push(element);
                }
              });
            }
            item.children.forEach((item1) => {
              if (item1.fileData) {
                item1.fileData.forEach((item2) => {
                  if (element.GROUPGUID == item2.groupGuid) {
                    this.getFileUrl(element, item2);
                    // element["isImage"] = true;
                    // element["url"] =
                    //   window.g.BaseURL +
                    //   "FileServer/api/Preview?token=" +
                    //   window.localStorage.getItem("token") +
                    //   "&" +
                    //   "fileGuid=" +
                    //   encodeURIComponent(element.ROW_GUID);
                    // item2.fileList.push(element);
                  }
                });
              }
            });
          });
        });
      }
    },
    getFileUrl: async function (element, item) {
      let formData = new FormData();
      formData.append("accessCode", "98bcf528966e48ce896a8b3fd02d45d5");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append(
        "paramStr",
        JSON.stringify({
          fileGuid: element.ROW_GUID,
        })
      );
      let response = await dataTransFilePreview(formData);
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers["content-type"],
        }); //type类型可自定义
        element["isImage"] = true;
        element["url"] = window.URL.createObjectURL(img);
        item.fileList.push(element);
      }
    },
  },
  mounted: function() {
    this.getYearsToNow();
    //获取当前市所有的区
    this.getXianOpenDataView4(this.$route.query.citycode);
    this.fwIdData = this.guid();
    if (this.$route.query.data == "新增") {
      this.isAdd = true;
      this.isZJ = true;
      this.fwIdData = this.guid();
      this.isFWLX = true;
    } else {
      this.isFWLX = false;
      this.rowData = JSON.parse(this.$route.query.data);
      let rowData = JSON.parse(this.$route.query.data);
      let type = 0;
      if (this.$route.query.data1 == 0) {
        if (rowData.CHECK_FINAL_RESULT=='0'){
          this.isAdd = true;
        }else{
          this.isAdd = false;
        }
        this.typeData = 3;
      } else {
        this.isAdd = false;
      }
      this.fwIdData = rowData.FWID;
      // if (rowData.FWLX==='自建房'){
      //   this.isZJ = true
      //   type = 0
      //   this.formDataPC.farmhouse_type = "0"
      // }else{
      //   this.isZJ = false
      //   type = 1
      //   this.formDataPC.farmhouse_type = "1"
      // }
      this.getData(this.fwIdData, type);
      this.getFile();
    }
    this.getEnumeration1();
    this.initializeCode();
    dd.ready(function() {
      dd.setTitle({
        title: "农房安全排查"
      })
        .then((res) => {
        })
        .catch((err) => {
          console.error(err);
        });
    });
  }
};
</script>

<style scoped lang="scss">
#keyInspectionAdd {
  height: 100vh;
  overflow-y: auto;
  padding: 10px;

  .line {
    width: 6px;
    height: 26px;
    background: #007aff;
    display: inline-block;
    margin-right: 10px;
  }
  .list ul li {
    min-height: 50px;
    line-height: 50px;
  }
  .footer {
    text-align: center;
    padding: 10px;
  }
}
</style>
<style lang="scss">
#keyInspectionAdd {
  .van-field__control {
    text-align: right !important;
  }
}
</style>
